<?php if (!defined('THINK_PATH')) exit();?><style>
	.zds_view_tool{
	background-color: #E0ECFF;
}
.zdc_mpdel_version{
	padding: 2px 25px 5px 2px;
    text-align: right;
    font-size: 14px;
}
.zds_tb{
	border: 2px solid;
    width: 98%;

}
.zds_footer{

    width: 100%;
    text-align: center;
}
.zds_tb td{
    border: 1px solid;
    padding:4px;
}
.zds_footer td{
    border: 1px solid #999;
}
.sqjt{
	width:100px;
	text-align: center;
}

.zds{
	font-size: 20px;
	width:220px;
	text-align: center;
}
.cx{
	font-size: 12px;
	width:200px;
	text-align: center;
}
.gw{
	font-size: 20px;
	width:100px;
	text-align: center;
}
.title{
	font-size: 20px;
	width:140px;
	text-align: center;
}
.ids{
	font-size: 20px;
	width:140px;
	text-align: center;
}

.zds_content{
	height: 500px;
	vertical-align: top;
}

</style>

<div class="zds_view_tool">
	<table>
		<tr>
		<td>
            <input  type="hidden" id="zds_id" value="<?php echo ($data[id]); ?>">

           


				<?php if($index == 'checker'): ?><a href="#"  class="easyui-linkbutton"  onclick="ok_zds('<?php echo ($index); ?>','<?php echo ($data[id]); ?>','s2')" data-options="iconCls:'icon-ok',plain:true">校对</a>
					<a href="#"  class="easyui-linkbutton"  onclick="backgo_zds('<?php echo ($index); ?>','<?php echo ($data[id]); ?>')" data-options="iconCls:'icon-standard-application-side-contract',plain:true">驳回</a><?php endif; ?>
				<?php if($index == 'examine'): ?><a href="#"  class="easyui-linkbutton"  onclick="ok_zds('<?php echo ($index); ?>','<?php echo ($data[id]); ?>','s3')" data-options="iconCls:'icon-ok',plain:true">审核</a>
					<a href="#"  class="easyui-linkbutton"  onclick="backgo_zds('<?php echo ($index); ?>','<?php echo ($data[id]); ?>')" data-options="iconCls:'icon-standard-application-side-contract',plain:true">驳回</a><?php endif; ?>
            <?php if($index == 'approve'): ?><a href="#"  class="easyui-linkbutton"  onclick="ok_zds('<?php echo ($index); ?>','<?php echo ($data[id]); ?>','s4')" data-options="iconCls:'icon-ok',plain:true">批准</a>
                <a href="#"  class="easyui-linkbutton"  onclick="backgo_zds('<?php echo ($index); ?>','<?php echo ($data[id]); ?>')" data-options="iconCls:'icon-standard-application-side-contract',plain:true">驳回</a><?php endif; ?>
            <?php if(($index == 'invalid') OR ($index == 'approve')): ?><a href="#"  class="easyui-linkbutton"  onclick="invalid('<?php echo ($index); ?>','<?php echo ($data[id]); ?>')" data-options="iconCls:'icon-standard-application-side-contract',plain:true">作废</a>
                <a href="#"  class="easyui-linkbutton"  onclick="backgo_zds('<?php echo ($index); ?>','<?php echo ($data[id]); ?>')" data-options="iconCls:'icon-standard-application-side-contract',plain:true">驳回</a><?php endif; ?>

        <?php if($index == 'hq'): ?><a href="#"  class="easyui-linkbutton"  onclick="huiqian('<?php echo ($dwdh); ?>','<?php echo ($name); ?>')" data-options="iconCls:'icon-standard-application-side-contract',plain:true">会签</a><?php endif; ?>

            <!--<a href="#"  class="easyui-linkbutton"  onclick="ceshi()"  data-options="iconCls:'icon-standard-application-side-contract',plain:true">测试</a>-->
        <!-- <?php if($zuofei == 'true'): ?>-->
            <!--<?php endif; ?>  -->


			</td>	
		<td>
	    	<div class="datagrid-btn-separator"></div>
		</td>  
			<td>
				

					<a href="#"  class="easyui-linkbutton"  onclick="FullScrean()" data-options="iconCls:'icon-standard-monitor',plain:true">全屏</a>
					<a href="#"  class="easyui-linkbutton"  onclick='save_zds()' data-options="iconCls:'icon-standard-table-save',plain:true">下载</a>
					<a href="#"  class="easyui-linkbutton"  onclick='print_zds()' data-options="iconCls:'icon-standard-printer',plain:true">打印</a>
					<a href="#"  class="easyui-linkbutton"  onclick='go_back_zds("<?php echo ($index); ?>","<?php echo ($data[id]); ?>")' data-options="iconCls:'icon-back',plain:true">返回</a>

					<a href="#"  class="easyui-linkbutton"  onclick='plug()' data-options="iconCls:'icon-standard-server-uncompressed',plain:true">插件安装</a>

			</td>	

		</tr>

	</table>

</div>
<input type="hidden" id="id" name="id" value="<?php echo ($id); ?>">
<input type="hidden" id="docname" name="docname" value="<?php echo ($data['urls']); ?>">
<div id="ccdoc" class="easyui-layout" data-options="fit:true">
   <!--  <div data-options="region:'north',title:'North Title',split:true" style="height:100px;"></div>   
    <div data-options="region:'south',title:'South Title',split:true" style="height:100px;"></div>   
    <div data-options="region:'east',iconCls:'icon-reload',title:'East',split:true" style="width:100px;"></div>   
    <div data-options="region:'west',title:'West',split:true" style="width:100px;"></div>    -->
    <div data-options="region:'center',title:''" style="padding:0px;background:#eee;">
		
 <?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome')): ?><object id='WebOffice1' type='application/x-itst-activex' align='baseline' border='0'
                    style='LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT: 100%'
                    clsid='{E77E049B-23FC-4DB8-B756-60529A35FAD5}'
                    event_NotifyCtrlReady='WebOffice1_NotifyCtrlReady'
                    wmode='opaque'>
            </object><?php endif; ?>
        <?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')): ?><OBJECT id='WebOffice1' align='middle' style='LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT: 100%'
            classid='clsid:E77E049B-23FC-4DB8-B756-60529A35FAD5'
            event_NotifyCtrlReady='WebOffice1_NotifyCtrlReady'>
            </OBJECT><?php endif; ?>
        <?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox')): ?><object id='WebOffice1' type='application/x-itst-activex' align='baseline' border='0'
                    style='LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT: 100%'
            clsid='{E77E049B-23FC-4DB8-B756-60529A35FAD5}'
            event_NotifyCtrlReady='WebOffice1_NotifyCtrlReady'>
            </object><?php endif; ?>

    </div>   
</div> 


<!-- 下载插件 -->
<div id="plugd" class="easyui-dialog" style="width:335px; height: 212px;padding: 10px 50px; overflow:hidden;" title="&nbsp;&nbsp;下载插件" data-options="iconCls:'icon-standard-folder-page',buttons:'#dlg-plugd',closed:true,resizable:false,modal:true,closable:true">

    <a href="/solve/Public/word/weboffice7-exe.rar" target="_blank">&nbsp;weboffice插件</a><br>
    <a href="/solve/Public/word/ffactivex-setup-r39.rar" target="_blank">&nbsp;浏览器插件</a><br>
    请安装上面两个插件并在chrome浏览器或者360浏览器极速模式下使用作业指导书模块！
    <iframe id="iframe1" src="about:blank" frameBorder="0" marginHeight="0" marginWidth="0" style="position:absolute; visibility:inherit; top:0px;left:0px;width:100%; height:100%;z-index:-1; filter:alpha(opacity=0);"></iframe>

</div>

<div id="dlg-plugd">
    <!-- <div class="tool_tip">只有自己发布的装配问题记录才能进行编辑！！</div> -->
    <!-- <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="downplug()">确认</a> -->
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#plugd').dialog('close')">取消</a>
</div>
<div id="dg-bhxx" class="easyui-dialog" style="width: 580px; height: 240px; padding: 5px; overflow: hidden;" title="&nbsp;&nbsp;驳回信息" data-options="iconCls:'icon-standard-folder-page',buttons:'#dlg-bhxx-tool',closed:true,resizable:false,modal:true,closable:true">


    <form id="add_bxinfo" method="post">
        <input name="bxinfo" id="bxinfo" class="easyui-textbox" style="width: 100%; height: 150px;"  data-options="multiline:true,prompt:'请输入驳回信息...',required:true"/>
        <br />

    </form>


    <iframe id="iframe2" src="about:blank" frameBorder="0" marginHeight="0" marginWidth="0" style="position:absolute; visibility:inherit; top:0px;left:0px;width:100%; height:100%;z-index:-1; filter:alpha(opacity=0);"></iframe>

</div>
<div id="dlg-bhxx-tool">
    <!-- <div class="tool_tip">只有自己发布的装配问题记录才能进行编辑！！</div> -->
     <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="backgo_zds1('<?php echo ($index); ?>')">驳回</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dg-bhxx').dialog('close')">取消</a>
</div>



<script src="/solve/Public/App/zds/word.js"></script>
<script type="text/javascript">
function gobackfun(index) {
    var tab = $('#tab').tabs('getSelected');
    var laArr = ['brow','editor','checker','examine','approve','invalid'];
    var actionStr = ['showBrow', 'showEditor', 'showChecker', 'showExamine', 'showApprove','showInvalid'];
    var result = $.inArray(index, laArr);

    setTimeout(function () {
        var tab = $('#tab').tabs('getSelected');
        if ($('#WebOffice1')) {
            $('#WebOffice1').remove();
        }
        tab.panel('refresh', APP + '/Home/Zds/' + actionStr[result]);
    }, 2000);
}

  $(function(){
 // 当关闭tab时，销毁weboffice
// $('#tab').tabs({
//   onBeforeClose: function(title,index){
//     if($('#WebOffice1')){
//          $('#WebOffice1').remove();
//     }
//   }
// });
// ie需要再加载一次
 // if($.browser.msie) { 
 // 	WebOffice1_NotifyCtrlReady();
 //            // alert("this is msie!"); //IE
 //        };

  })

   // 初始化
function WebOffice1_NotifyCtrlReady() {
    webObj.ShowToolBar = false;

    var id = $("#id").val();
    var docname = $("#docname").val();
    webObj.LoadOriginalFile('http://192.168.8.200/wordupload/' + docname, "doc");
    ProtectFull();//文档保护
}

/**
 * [go_back_zds 返回]
 * @param  {[type]} index [description]
 * @return {[type]}       [description]
 */
function go_back_zds(index, id) {
// if(index=='editor'){
//     $.messager.confirm('确认','返回前需要保存吗？',function(r){
//         if (r){
//             var s = savezds(id);
//         }
//     });
//     windowMask();
// }

    // var s = savezds(id);
    // setTimeout(function () {
    //     gobackfun(index);
    // }, 2000);
    gobackfun(index);
}

// 会签
function huiqian(dh,name){
 var webObj=document.getElementById("WebOffice1");
 UnProtect();
  var stime = new Date().Format("yyyy-MM-dd");//编制日期
 webObj.SetFieldValue(dh, name,"");//编制
webObj.SetFieldValue(dh+'time', stime,"");//编制

savezds(id);

ProtectFull();//文档保护
}

function ceshi(){
    UnProtect();
    // 先去掉校对、审核、批准的书签
    var webObj=document.getElementById("WebOffice1");
    webObj.SetFieldValue("s2","","");//校对
    webObj.SetFieldValue("s2time","","");//校对
    webObj.SetFieldValue("s3","","");//校对
    webObj.SetFieldValue("s3time","","");//校对
    webObj.SetFieldValue("s4","","");//校对
    webObj.SetFieldValue("s4time","","");//校对

    ProtectFull();

    try{
        // webObj.ProtectDoc(1,1, 'fjp203219');

        var webObj = document.getElementById("WebOffice1");
        UnProtect();
        var obj;
        obj = new Object(webObj.GetDocumentObject());
        // 获得ActiveDocument

        var pInlineShape=obj.InlineShapes.Count;
        console.log('shukiang:'+pInlineShape);
        if(obj !=null){
            var pBookMarks;
// VAB接口获取书签集合
            pBookMarks = obj.Bookmarks;
            var num;
            for(var i=1;i<=pBookMarks.Count;i++){
                var name=pBookMarks.Item(i).Name;

                if(name=='s2'){
                    num=i;
                }
            }
            var pBookM = pBookMarks.Item(num);
            // webObj.SetFieldValue("s2","","");//校对
            // // obj.ActiveWindow.View.Type = 4;
            // // pBookM.Select;
            // var c=pBookM.Start;
            // var d=pBookM.End;

            obj.ActiveWindow.View.Type = 4;
            obj.ActiveWindow.View.SeekView=10;
            Selection.WholeStory;
            // Selection.SelectCell;
            Selection.Delete;
            // console.log(Selection);


            // Selection.SelectCell;
            // Selection.Delete;

            // var a=webObj.GetBMPos('s2',0);
            // var b=webObj.GetBMPos('s2',1);
            // console.log(a+','+b+':'+c+','+d);
            // obj.ActiveWindow.View.Type = 4;
            // obj.ActiveWindow.View.SeekView=10;
            // for(var i=1;i<=pRangeInlines.count;i++){
      //     console.log(i)
      // }

           //  var pShapeRange=pRange.ShapeRange;
           // var s= pShapeRange.Delete;

            // pRangeInlines = pRange.InlineShapes;
            //
            // markval = 'http://192.168.8.200/solve/public/' + sign;
            // pRangeInline = pRangeInlines.AddPicture(markval+"?w=218&h=146&s=B9C27A23024B3AE02C1DC0DF0100C082", false, true);
            //
            //
            // pRangeInline.Width = 60;
            // pRangeInline.Height = 20;
            // pRangeInline.ConvertToShape().WrapFormat.TYPE = 5;

            delete obj;
        }
    }catch(e){
        $.messager.alert('异常',"异常\r\nError:"+e+"\r\nError Code:"+e.number+"\r\nError Des:"+e.description);
        windowMask();
    }
}
function backgo_zds() {



        $('#dg-bhxx').window('open');
        $('#bxinfo').textbox('clear');
        console.log($('#bxinfo').textbox('getText'));
        // $("#hidepl").val(row.huifu);



}

/**
 * [backgo_zds 驳回]
 * @return {[type]} [description]
 */
function backgo_zds1(index){
var id=$('#zds_id').val();

UnProtect();
  // 先去掉校对、审核、批准的书签
  var webObj=document.getElementById("WebOffice1");
webObj.SetFieldValue("s2","","");//校对
webObj.SetFieldValue("s2time","","");//校对
webObj.SetFieldValue("s3","","");//校对
webObj.SetFieldValue("s3time","","");//校对
webObj.SetFieldValue("s4","","");//校对
webObj.SetFieldValue("s4time","","");//校对
savezds(id);
newSave();//保存
ProtectFull();


    $('#add_bxinfo').form('submit', {

        url : APP+'/Home/Zds/backgo',
        type:'POST',
        onSubmit: function(param){
            param.id = id;
        },
        success : function(data) {
            var data = eval('(' + data + ')');
            if (data.status==1) {


                //如果是普通浏览，不需要问保存不》？
                if(index!='brow'){
                    $('#dg-bhxx').window('close');
                    $.messager.confirm('确认',data.msg+"您想要返回列表页面吗？",function(r){
                        if (r){
                            if($('#WebOffice1')){
                                $('#WebOffice1').remove();
                            }
                            gobackfun(index);
                        }
                    });
                    windowMask();
                }
            } else {
                $.messager.alert('错误', data.msg);
                windowMask();
            }

        }
    });


  // 更改状态为1，驳回
// var info=$('#bxinfo').textbox('getValue');
// console.log(info);
// $.post(APP+'/Home/Zds/backgo', {
//           'id' : id, 'bxinfo' : info
//         }, function(data) {
//
//           if (data.status==1) {
//
//
//               //如果是普通浏览，不需要问保存不》？
//               if(index!='brow'){
//                   $('#dg-bhxx').window('close');
//                   $.messager.confirm('确认',data.msg+"您想要返回列表页面吗？",function(r){
//                       if (r){
//                           if($('#WebOffice1')){
//                               $('#WebOffice1').remove();
//                           }
//                           gobackfun(index);
//                       }
//                   });
//                   windowMask();
//               }
//           } else {
//               $.messager.alert('错误', data.msg);
//               windowMask();
//           }
//         }, 'json');
}
// 通过


function ok_zds(index, id,qmwz) {
    var webObj = document.getElementById("WebOffice1");
    UnProtect();
    var returnValue;
    webObj.HttpInit();

    $.post(APP + '/Home/Zds/' + index + '_ok', {
        id: id
    }, function (data) {




        if (data.status == 1) {
            // 更新word中的标签
// data=$.parseJSON(data);
            var stime = new Date().Format("yyyy-MM-dd");//编制日期

            var sign = "<?php echo ($_SESSION[ 'sign']); ?>";


            UnProtect();

            // 如果是审核
            if(qmwz=='s4'){

                if(sign!=''){
                    // signName('s4',sign);
                    webObj.SetFieldValue('s4', data.lcval, "");//编制
                }else{
                    webObj.SetFieldValue('s4', data.lcval, "");//编制
                }
                webObj.SetFieldValue('s4time', stime, "");//编制

                // signName('s4','upload/sign/wangbin.JPG');
                // webObj.SetFieldValue('s4time', stime, "");//编制

                webObj.SetFieldValue('ids', data.ids, "");//编制

                webObj.HttpAddPostString("ids", data.ids);

            }else{
                if(sign!=''){
                    // signName(qmwz,sign);
                    webObj.SetFieldValue(qmwz, data.lcval, "");//编制
                }else{
                    webObj.SetFieldValue(qmwz, data.lcval, "");//编制
                }
                webObj.SetFieldValue(qmwz + 'time', stime, "");//编制
                webObj.HttpAddPostString("ids", '');
            }



            // 如果是批准，就受控
            if(index=='approve'){
                // shoukong();
                console.log('此处签受控章');
            }
            ProtectFull();
// console.log(data.lc);
// console.log(data.lcval);

            webObj.HttpAddPostString("ida", id);
            webObj.HttpAddPostString("title", data.title);
            webObj.HttpAddPostString("DocType", "doc");
            webObj.HttpAddPostCurrFile("DocContent", "");
            newSave();//保存
            returnValue = webObj.HttpPost('http://192.168.8.200/wordupload/savedoc.php?id=' + id + '&number=Math.random()');  // 判断上传是否成功

console.log(returnValue);
            if (returnValue == "succeed") {

                $.messager.confirm('确认', '您想要返回列表页面吗？', function (r) {
                    if (r) {
                        $('#mainLay').layout('expand', 'west');
                        if ($('#WebOffice1')) {
                            $('#WebOffice1').remove();
                        }
                        gobackfun(index);
                    }
                });
                windowMask();
            } else if (returnValue == "failed")

                $.messager.alert('失败', '文件上传失败');
            windowMask();
        } else {

            $.messager.alert('错误', data.data);
            windowMask();
        }
    }, 'json');
}

function plug(){
$("#plugd").dialog("open").dialog('setTitle', '&nbsp;&nbsp;下载插件');
}
</script>